package com.bjpowernode.javase.collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorTest {
    public static void main(String[] args) {
        List<String> stringList = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            stringList.add("sun"+i);
        }

        Iterator<String> iterator = stringList.iterator();
        if (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
            iterator.remove();
        }

        System.out.println(stringList);
    }
}
